package com.sykj.why.controller.front.content;

import com.sykj.why.exception.WhyException;
import com.sykj.why.handler.Response;
import com.sykj.why.mongo.enums.exception.ResultEnum;
import com.sykj.why.mongo.service.ContentTService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author Eleven
 * @date 2019/6/18
 * @desc 前端内容控制访问层
 */

@RestController
@RequestMapping("/front/content")
@Slf4j
@Api(value = "/front/content",description = "前端内容控制访问层")
public class FrontContentController {

    @Autowired
    private ContentTService contentTService;

    /**
     * 查看专辑详情
     * @param albumId
     * @param categoryId
     * @return
     */
    @RequestMapping(value = "/getContentDetail",method = RequestMethod.GET)
    @ApiOperation(value = "/getContentDetail",notes = "查看专辑详情")
    public ResponseEntity getContentDetail(@RequestParam String albumId,@RequestParam String categoryId){
        try {
            return Response.success("查询成功", contentTService.findByAlbum(albumId,categoryId));
        } catch (WhyException e) {
            return Response.serverError(e.getMessage(), e.getCode());
        } catch (Exception e) {
            log.error("查看专辑详情出现异常，{}", e.getMessage());
            return Response.serverError(ResultEnum.UNERROR.getMessage(), ResultEnum.UNERROR.getCode());
        }
    }

}
